<?php
header("content-type:text/html;charset=utf-8");
session_start();
include "public/is_login.php";
include "../public/config/config.php";
include "../public/include/funcs.php";

$id = $_GET['id'] ? $_GET['id'] : $_SESSION['id'];
if(!$id) $id = $did;
$aid = $_GET['aid'];

$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);

$arr = select($link, "user", "id=$id");
$name = $arr[0]['tname'] ? $arr[0]['tname'] : $arr[0]['nickname'];
$u_img = $arr[0]['u_img'];
$pid = $arr[0]['pid'];

$awa_arr = select($link, "award", "a_id=$aid");
$a_id = $awa_arr[0]['a_id'];
$at_id = $awa_arr[0]['at_id'];
$award = $awa_arr[0]['award'];
$state = $awa_arr[0]['state'];
$ma = $awa_arr[0]['ma'];
$int_time = $awa_arr[0]['int_time'];

$state_arr=["待领取","已领取"];

$at_arr = select($link, "awa_type");
$at = array();
foreach($at_arr as $v){
	$at[$v['at_id']] = $v['type_name'];
}

mysqli_close($link);
//echo "<pre>";
//print_r($awa_arr);
//print_r($parr);
//echo "</pre>";
?>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>分享商城 -- <?php echo $award;?></title>
	
	<!-- Bootstrap -->
	<link href="/public/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="public/main.css"/>
	
	<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
	<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
	<![endif]-->
</head>
<body class="bg_green">

<!--<div class="container">
	<img class="list-logo" src="imgs/list/logo.png"/>
</div>-->

<div class="head_top">
	<div class="u_img">
		<img class="img-rounded" src="<?php echo $u_img;?>"/>
	</div>
	<div class="u_name">
		<p class="u_title"><?php echo $name;?></p>
		<p class="u_id">ID号：<?php echo $id;?></p>
	</div>
	<div class="clear"></div>
</div>

<div class="cell_code">
	<p class="zs_p">向商家展示奖品核验码</p>
	<div class="code_img">
		<img src="barcode/barcode.php?text=<?php echo $ma;?>"/>
		<hr />
		<img src="public/qrcode.php?text=<?php echo $ma;?>"/>
	</div>
</div>


	
<div class="award_info">
	<table class="table1">
		<tr>
			<td>奖品ID：</td>
			<td><?php echo $a_id;?></td>
		</tr>
		<tr>
			<td>奖品名称：</td>
			<td><?php echo $award;?></td>
		</tr>
		<tr>
			<td>奖品来源：</td>
			<td><?php echo $at[$at_id];?></td>
		</tr>
		<tr>
			<td>奖品状态：</td>
			<td><?php echo $state_arr[$state];?></td>
		</tr>
		<tr>
			<td>奖品核验码：</td>
			<td><?php echo $ma;?></td>
		</tr>
		<tr id="tr_no">
			<td>奖品获得时间：</td>
			<td><?php echo date("Y-m-d H:i:s",$int_time);?></td>
		</tr>
		
	</table>
</div>

<?php include "template/footer.php";?>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
<script type="text/javascript">
	function msg(){
		alert("敬请期待...");
	}
</script>
</body>
</html>